{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "df = pd.read_excel(r'./material/data_sample_sales.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2666, 12)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape  # (2666, 11) (行, 列)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>amount</th>\n",
       "      <th>code</th>\n",
       "      <th>discount</th>\n",
       "      <th>fk_clerk</th>\n",
       "      <th>fk_customer</th>\n",
       "      <th>fk_store</th>\n",
       "      <th>id</th>\n",
       "      <th>info</th>\n",
       "      <th>interests</th>\n",
       "      <th>modified</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>created</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-01-01 15:59:25</th>\n",
       "      <td>0</td>\n",
       "      <td>498</td>\n",
       "      <td>20190415154659549312SZ5BEK</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>477</td>\n",
       "      <td>5</td>\n",
       "      <td>14955</td>\n",
       "      <td>NaN</td>\n",
       "      <td>250</td>\n",
       "      <td>2019-04-15 15:46:59.549</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-02 14:14:14</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659577157MLXRLN</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>449</td>\n",
       "      <td>9</td>\n",
       "      <td>14959</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.577</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-02 14:16:19</th>\n",
       "      <td>2</td>\n",
       "      <td>398</td>\n",
       "      <td>20190415154659582312XXK1NI</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>488</td>\n",
       "      <td>5</td>\n",
       "      <td>14960</td>\n",
       "      <td>NaN</td>\n",
       "      <td>200</td>\n",
       "      <td>2019-04-15 15:46:59.582</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-02 14:29:50</th>\n",
       "      <td>3</td>\n",
       "      <td>398</td>\n",
       "      <td>20190415154659564684H8BNY2</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>512</td>\n",
       "      <td>5</td>\n",
       "      <td>14957</td>\n",
       "      <td>NaN</td>\n",
       "      <td>200</td>\n",
       "      <td>2019-04-15 15:46:59.565</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-02 14:59:43</th>\n",
       "      <td>4</td>\n",
       "      <td>248</td>\n",
       "      <td>20190415154659557965GODCWB</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>466</td>\n",
       "      <td>9</td>\n",
       "      <td>14956</td>\n",
       "      <td>NaN</td>\n",
       "      <td>125</td>\n",
       "      <td>2019-04-15 15:46:59.558</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-02 16:30:59</th>\n",
       "      <td>5</td>\n",
       "      <td>696</td>\n",
       "      <td>201904151546595711670RYCZ8</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>512</td>\n",
       "      <td>5</td>\n",
       "      <td>14958</td>\n",
       "      <td>NaN</td>\n",
       "      <td>350</td>\n",
       "      <td>2019-04-15 15:46:59.571</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03 12:09:35</th>\n",
       "      <td>6</td>\n",
       "      <td>756</td>\n",
       "      <td>20190415154659588954ZBRGD4</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>430</td>\n",
       "      <td>5</td>\n",
       "      <td>14961</td>\n",
       "      <td>NaN</td>\n",
       "      <td>380</td>\n",
       "      <td>2019-04-15 15:46:59.589</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03 16:26:07</th>\n",
       "      <td>7</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154659601379R3WS29</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>444</td>\n",
       "      <td>9</td>\n",
       "      <td>14963</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.601</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03 19:50:49</th>\n",
       "      <td>8</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659607804FYCFL5</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>459</td>\n",
       "      <td>5</td>\n",
       "      <td>14964</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.608</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03 20:22:59</th>\n",
       "      <td>9</td>\n",
       "      <td>0</td>\n",
       "      <td>201904151546595953817ZGUHP</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>504</td>\n",
       "      <td>5</td>\n",
       "      <td>14962</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.595</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03 20:51:52</th>\n",
       "      <td>10</td>\n",
       "      <td>448</td>\n",
       "      <td>20190415154659061355FX8DRG</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>505</td>\n",
       "      <td>5</td>\n",
       "      <td>14965</td>\n",
       "      <td>NaN</td>\n",
       "      <td>225</td>\n",
       "      <td>2019-04-15 15:46:59.614</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04 10:07:53</th>\n",
       "      <td>11</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659643557E65LLM</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>468</td>\n",
       "      <td>5</td>\n",
       "      <td>14970</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.644</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04 13:32:36</th>\n",
       "      <td>12</td>\n",
       "      <td>258</td>\n",
       "      <td>20190415154659631144VFK7OV</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>502</td>\n",
       "      <td>5</td>\n",
       "      <td>14968</td>\n",
       "      <td>NaN</td>\n",
       "      <td>130</td>\n",
       "      <td>2019-04-15 15:46:59.631</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04 16:25:16</th>\n",
       "      <td>13</td>\n",
       "      <td>348</td>\n",
       "      <td>20190415154659619885U334Z4</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>460</td>\n",
       "      <td>5</td>\n",
       "      <td>14966</td>\n",
       "      <td>NaN</td>\n",
       "      <td>175</td>\n",
       "      <td>2019-04-15 15:46:59.620</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04 17:11:55</th>\n",
       "      <td>14</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154659626406FEXJGN</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>496</td>\n",
       "      <td>9</td>\n",
       "      <td>14967</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.626</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04 20:15:12</th>\n",
       "      <td>15</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659637351EO7IUK</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>473</td>\n",
       "      <td>5</td>\n",
       "      <td>14969</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.637</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05 13:14:55</th>\n",
       "      <td>16</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154659648245NWRXHO</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>432</td>\n",
       "      <td>9</td>\n",
       "      <td>14971</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.648</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05 14:22:02</th>\n",
       "      <td>17</td>\n",
       "      <td>249</td>\n",
       "      <td>20190415154659653002H40CZE</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>505</td>\n",
       "      <td>9</td>\n",
       "      <td>14972</td>\n",
       "      <td>NaN</td>\n",
       "      <td>125</td>\n",
       "      <td>2019-04-15 15:46:59.653</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05 18:30:23</th>\n",
       "      <td>18</td>\n",
       "      <td>0</td>\n",
       "      <td>201904151546596583850QY6RP</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>512</td>\n",
       "      <td>5</td>\n",
       "      <td>14973</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.658</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-06 10:08:22</th>\n",
       "      <td>19</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659663347ZXMJ6R</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>462</td>\n",
       "      <td>9</td>\n",
       "      <td>14974</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.663</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-07 11:19:00</th>\n",
       "      <td>20</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154659668583JV256H</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>475</td>\n",
       "      <td>5</td>\n",
       "      <td>14975</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.669</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-08 17:51:25</th>\n",
       "      <td>21</td>\n",
       "      <td>198</td>\n",
       "      <td>201904151546596739278HL5J0</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>477</td>\n",
       "      <td>9</td>\n",
       "      <td>14976</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.674</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09 13:10:16</th>\n",
       "      <td>22</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154659683959JOSILY</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>516</td>\n",
       "      <td>9</td>\n",
       "      <td>14978</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.684</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09 16:08:44</th>\n",
       "      <td>23</td>\n",
       "      <td>99</td>\n",
       "      <td>20190415154659694079JIF96R</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>454</td>\n",
       "      <td>9</td>\n",
       "      <td>14980</td>\n",
       "      <td>NaN</td>\n",
       "      <td>50</td>\n",
       "      <td>2019-04-15 15:46:59.694</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09 16:51:26</th>\n",
       "      <td>24</td>\n",
       "      <td>99</td>\n",
       "      <td>2019041515465969875674DSE9</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>472</td>\n",
       "      <td>5</td>\n",
       "      <td>14981</td>\n",
       "      <td>NaN</td>\n",
       "      <td>50</td>\n",
       "      <td>2019-04-15 15:46:59.699</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09 19:28:12</th>\n",
       "      <td>25</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154659679362IOES1X</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>513</td>\n",
       "      <td>5</td>\n",
       "      <td>14977</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:46:59.679</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-09 20:27:23</th>\n",
       "      <td>26</td>\n",
       "      <td>697</td>\n",
       "      <td>20190415154659688586CP2NOT</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>488</td>\n",
       "      <td>5</td>\n",
       "      <td>14979</td>\n",
       "      <td>NaN</td>\n",
       "      <td>350</td>\n",
       "      <td>2019-04-15 15:46:59.689</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-10 17:37:59</th>\n",
       "      <td>27</td>\n",
       "      <td>0</td>\n",
       "      <td>201904151546597034085ZXWIV</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>504</td>\n",
       "      <td>5</td>\n",
       "      <td>14982</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:46:59.703</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-11 11:38:34</th>\n",
       "      <td>28</td>\n",
       "      <td>456</td>\n",
       "      <td>20190415154659709425JF04MA</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>436</td>\n",
       "      <td>5</td>\n",
       "      <td>14983</td>\n",
       "      <td>NaN</td>\n",
       "      <td>230</td>\n",
       "      <td>2019-04-15 15:46:59.709</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-12 13:55:56</th>\n",
       "      <td>29</td>\n",
       "      <td>297</td>\n",
       "      <td>20190415154659714836B30RVJ</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>461</td>\n",
       "      <td>5</td>\n",
       "      <td>14984</td>\n",
       "      <td>NaN</td>\n",
       "      <td>150</td>\n",
       "      <td>2019-04-15 15:46:59.715</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-22 18:01:43</th>\n",
       "      <td>1101</td>\n",
       "      <td>99</td>\n",
       "      <td>20190415154705205826MNTFO8</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>429</td>\n",
       "      <td>9</td>\n",
       "      <td>16056</td>\n",
       "      <td>NaN</td>\n",
       "      <td>50</td>\n",
       "      <td>2019-04-15 15:47:05.206</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-23 11:58:43</th>\n",
       "      <td>1102</td>\n",
       "      <td>199</td>\n",
       "      <td>20190415154705221015UK8M67</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>439</td>\n",
       "      <td>5</td>\n",
       "      <td>16059</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.221</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-23 16:23:01</th>\n",
       "      <td>1103</td>\n",
       "      <td>456</td>\n",
       "      <td>201904151547052162780JP6KG</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>500</td>\n",
       "      <td>9</td>\n",
       "      <td>16058</td>\n",
       "      <td>NaN</td>\n",
       "      <td>230</td>\n",
       "      <td>2019-04-15 15:47:05.216</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-23 17:18:40</th>\n",
       "      <td>1104</td>\n",
       "      <td>507</td>\n",
       "      <td>20190415154705211439V5WAPS</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>458</td>\n",
       "      <td>9</td>\n",
       "      <td>16057</td>\n",
       "      <td>NaN</td>\n",
       "      <td>255</td>\n",
       "      <td>2019-04-15 15:47:05.211</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-24 11:38:13</th>\n",
       "      <td>1105</td>\n",
       "      <td>794</td>\n",
       "      <td>201904151547052412085ZEB2Q</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>483</td>\n",
       "      <td>5</td>\n",
       "      <td>16063</td>\n",
       "      <td>NaN</td>\n",
       "      <td>400</td>\n",
       "      <td>2019-04-15 15:47:05.241</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-24 14:14:29</th>\n",
       "      <td>1106</td>\n",
       "      <td>546</td>\n",
       "      <td>20190415154705235993N1TSJG</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>430</td>\n",
       "      <td>9</td>\n",
       "      <td>16062</td>\n",
       "      <td>NaN</td>\n",
       "      <td>275</td>\n",
       "      <td>2019-04-15 15:47:05.236</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-24 15:04:36</th>\n",
       "      <td>1107</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705231187R09G6S</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>495</td>\n",
       "      <td>5</td>\n",
       "      <td>16061</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.231</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-24 18:21:44</th>\n",
       "      <td>1108</td>\n",
       "      <td>995</td>\n",
       "      <td>20190415154705225895AM0860</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>471</td>\n",
       "      <td>9</td>\n",
       "      <td>16060</td>\n",
       "      <td>NaN</td>\n",
       "      <td>500</td>\n",
       "      <td>2019-04-15 15:47:05.226</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-24 19:49:35</th>\n",
       "      <td>1109</td>\n",
       "      <td>198</td>\n",
       "      <td>201904151547052460536XEBCV</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>467</td>\n",
       "      <td>9</td>\n",
       "      <td>16064</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.246</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-25 20:16:54</th>\n",
       "      <td>1110</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705251113DLT045</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>501</td>\n",
       "      <td>5</td>\n",
       "      <td>16065</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.251</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-26 11:01:24</th>\n",
       "      <td>1111</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705265762TM29X5</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>453</td>\n",
       "      <td>9</td>\n",
       "      <td>16068</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.266</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-26 13:20:47</th>\n",
       "      <td>1112</td>\n",
       "      <td>99</td>\n",
       "      <td>2019041515470525583617ME1T</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>431</td>\n",
       "      <td>9</td>\n",
       "      <td>16066</td>\n",
       "      <td>NaN</td>\n",
       "      <td>50</td>\n",
       "      <td>2019-04-15 15:47:05.256</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-26 15:14:08</th>\n",
       "      <td>1113</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705260799JZG9PE</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>515</td>\n",
       "      <td>9</td>\n",
       "      <td>16067</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.261</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-27 11:10:44</th>\n",
       "      <td>1114</td>\n",
       "      <td>747</td>\n",
       "      <td>201904151547052706148Q9EUR</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>457</td>\n",
       "      <td>9</td>\n",
       "      <td>16069</td>\n",
       "      <td>NaN</td>\n",
       "      <td>375</td>\n",
       "      <td>2019-04-15 15:47:05.271</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-27 11:44:07</th>\n",
       "      <td>1115</td>\n",
       "      <td>298</td>\n",
       "      <td>20190415154705280471UFM00J</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>474</td>\n",
       "      <td>5</td>\n",
       "      <td>16071</td>\n",
       "      <td>NaN</td>\n",
       "      <td>150</td>\n",
       "      <td>2019-04-15 15:47:05.280</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-27 20:32:51</th>\n",
       "      <td>1116</td>\n",
       "      <td>498</td>\n",
       "      <td>20190415154705275516NRE3P3</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>487</td>\n",
       "      <td>9</td>\n",
       "      <td>16070</td>\n",
       "      <td>NaN</td>\n",
       "      <td>250</td>\n",
       "      <td>2019-04-15 15:47:05.276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-28 14:47:15</th>\n",
       "      <td>1117</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154705290007YF94X8</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>462</td>\n",
       "      <td>9</td>\n",
       "      <td>16073</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:47:05.290</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-28 16:55:21</th>\n",
       "      <td>1118</td>\n",
       "      <td>448</td>\n",
       "      <td>20190415154705285238A0E3CQ</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>452</td>\n",
       "      <td>5</td>\n",
       "      <td>16072</td>\n",
       "      <td>NaN</td>\n",
       "      <td>225</td>\n",
       "      <td>2019-04-15 15:47:05.285</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-28 20:01:30</th>\n",
       "      <td>1119</td>\n",
       "      <td>99</td>\n",
       "      <td>20190415154705295044EO89UU</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>517</td>\n",
       "      <td>9</td>\n",
       "      <td>16074</td>\n",
       "      <td>NaN</td>\n",
       "      <td>50</td>\n",
       "      <td>2019-04-15 15:47:05.295</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29 11:54:40</th>\n",
       "      <td>1120</td>\n",
       "      <td>149</td>\n",
       "      <td>20190415154705299695TSY50A</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>477</td>\n",
       "      <td>5</td>\n",
       "      <td>16075</td>\n",
       "      <td>NaN</td>\n",
       "      <td>75</td>\n",
       "      <td>2019-04-15 15:47:05.300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29 12:37:25</th>\n",
       "      <td>1121</td>\n",
       "      <td>199</td>\n",
       "      <td>20190415154705312232Q445LC</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>478</td>\n",
       "      <td>9</td>\n",
       "      <td>16077</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29 18:28:30</th>\n",
       "      <td>1122</td>\n",
       "      <td>398</td>\n",
       "      <td>20190415154705317722AV2I6U</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>516</td>\n",
       "      <td>5</td>\n",
       "      <td>16078</td>\n",
       "      <td>NaN</td>\n",
       "      <td>200</td>\n",
       "      <td>2019-04-15 15:47:05.318</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29 18:51:16</th>\n",
       "      <td>1123</td>\n",
       "      <td>696</td>\n",
       "      <td>201904151547053072316M0C1C</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>474</td>\n",
       "      <td>5</td>\n",
       "      <td>16076</td>\n",
       "      <td>NaN</td>\n",
       "      <td>350</td>\n",
       "      <td>2019-04-15 15:47:05.307</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-29 19:21:45</th>\n",
       "      <td>1124</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705322455HFLPOG</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>441</td>\n",
       "      <td>5</td>\n",
       "      <td>16079</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.322</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-30 11:34:08</th>\n",
       "      <td>1125</td>\n",
       "      <td>199</td>\n",
       "      <td>20190415154705032764Z75VQK</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>502</td>\n",
       "      <td>9</td>\n",
       "      <td>16080</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31 10:34:35</th>\n",
       "      <td>1126</td>\n",
       "      <td>715</td>\n",
       "      <td>201904151547053436824AQH3Y</td>\n",
       "      <td>0</td>\n",
       "      <td>522</td>\n",
       "      <td>495</td>\n",
       "      <td>9</td>\n",
       "      <td>16083</td>\n",
       "      <td>NaN</td>\n",
       "      <td>360</td>\n",
       "      <td>2019-04-15 15:47:05.344</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31 11:23:15</th>\n",
       "      <td>1127</td>\n",
       "      <td>547</td>\n",
       "      <td>20190415154705353833TQU9C1</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>476</td>\n",
       "      <td>9</td>\n",
       "      <td>16085</td>\n",
       "      <td>NaN</td>\n",
       "      <td>275</td>\n",
       "      <td>2019-04-15 15:47:05.354</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31 15:14:47</th>\n",
       "      <td>1128</td>\n",
       "      <td>0</td>\n",
       "      <td>20190415154705332302R0ZIKM</td>\n",
       "      <td>0</td>\n",
       "      <td>19</td>\n",
       "      <td>440</td>\n",
       "      <td>9</td>\n",
       "      <td>16081</td>\n",
       "      <td>NaN</td>\n",
       "      <td>0</td>\n",
       "      <td>2019-04-15 15:47:05.332</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31 17:12:01</th>\n",
       "      <td>1129</td>\n",
       "      <td>397</td>\n",
       "      <td>20190415154705337204XEXGUH</td>\n",
       "      <td>0</td>\n",
       "      <td>521</td>\n",
       "      <td>428</td>\n",
       "      <td>9</td>\n",
       "      <td>16082</td>\n",
       "      <td>NaN</td>\n",
       "      <td>200</td>\n",
       "      <td>2019-04-15 15:47:05.337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-31 20:50:11</th>\n",
       "      <td>1130</td>\n",
       "      <td>198</td>\n",
       "      <td>20190415154705348809QF0CXA</td>\n",
       "      <td>0</td>\n",
       "      <td>520</td>\n",
       "      <td>432</td>\n",
       "      <td>9</td>\n",
       "      <td>16084</td>\n",
       "      <td>NaN</td>\n",
       "      <td>100</td>\n",
       "      <td>2019-04-15 15:47:05.349</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1131 rows × 11 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Unnamed: 0  amount                        code  discount  \\\n",
       "created                                                                         \n",
       "2017-01-01 15:59:25           0     498  20190415154659549312SZ5BEK         0   \n",
       "2017-01-02 14:14:14           1       0  20190415154659577157MLXRLN         0   \n",
       "2017-01-02 14:16:19           2     398  20190415154659582312XXK1NI         0   \n",
       "2017-01-02 14:29:50           3     398  20190415154659564684H8BNY2         0   \n",
       "2017-01-02 14:59:43           4     248  20190415154659557965GODCWB         0   \n",
       "2017-01-02 16:30:59           5     696  201904151546595711670RYCZ8         0   \n",
       "2017-01-03 12:09:35           6     756  20190415154659588954ZBRGD4         0   \n",
       "2017-01-03 16:26:07           7     198  20190415154659601379R3WS29         0   \n",
       "2017-01-03 19:50:49           8       0  20190415154659607804FYCFL5         0   \n",
       "2017-01-03 20:22:59           9       0  201904151546595953817ZGUHP         0   \n",
       "2017-01-03 20:51:52          10     448  20190415154659061355FX8DRG         0   \n",
       "2017-01-04 10:07:53          11       0  20190415154659643557E65LLM         0   \n",
       "2017-01-04 13:32:36          12     258  20190415154659631144VFK7OV         0   \n",
       "2017-01-04 16:25:16          13     348  20190415154659619885U334Z4         0   \n",
       "2017-01-04 17:11:55          14     198  20190415154659626406FEXJGN         0   \n",
       "2017-01-04 20:15:12          15       0  20190415154659637351EO7IUK         0   \n",
       "2017-01-05 13:14:55          16     198  20190415154659648245NWRXHO         0   \n",
       "2017-01-05 14:22:02          17     249  20190415154659653002H40CZE         0   \n",
       "2017-01-05 18:30:23          18       0  201904151546596583850QY6RP         0   \n",
       "2017-01-06 10:08:22          19       0  20190415154659663347ZXMJ6R         0   \n",
       "2017-01-07 11:19:00          20     198  20190415154659668583JV256H         0   \n",
       "2017-01-08 17:51:25          21     198  201904151546596739278HL5J0         0   \n",
       "2017-01-09 13:10:16          22       0  20190415154659683959JOSILY         0   \n",
       "2017-01-09 16:08:44          23      99  20190415154659694079JIF96R         0   \n",
       "2017-01-09 16:51:26          24      99  2019041515465969875674DSE9         0   \n",
       "2017-01-09 19:28:12          25     198  20190415154659679362IOES1X         0   \n",
       "2017-01-09 20:27:23          26     697  20190415154659688586CP2NOT         0   \n",
       "2017-01-10 17:37:59          27       0  201904151546597034085ZXWIV         0   \n",
       "2017-01-11 11:38:34          28     456  20190415154659709425JF04MA         0   \n",
       "2017-01-12 13:55:56          29     297  20190415154659714836B30RVJ         0   \n",
       "...                         ...     ...                         ...       ...   \n",
       "2017-12-22 18:01:43        1101      99  20190415154705205826MNTFO8         0   \n",
       "2017-12-23 11:58:43        1102     199  20190415154705221015UK8M67         0   \n",
       "2017-12-23 16:23:01        1103     456  201904151547052162780JP6KG         0   \n",
       "2017-12-23 17:18:40        1104     507  20190415154705211439V5WAPS         0   \n",
       "2017-12-24 11:38:13        1105     794  201904151547052412085ZEB2Q         0   \n",
       "2017-12-24 14:14:29        1106     546  20190415154705235993N1TSJG         0   \n",
       "2017-12-24 15:04:36        1107     198  20190415154705231187R09G6S         0   \n",
       "2017-12-24 18:21:44        1108     995  20190415154705225895AM0860         0   \n",
       "2017-12-24 19:49:35        1109     198  201904151547052460536XEBCV         0   \n",
       "2017-12-25 20:16:54        1110     198  20190415154705251113DLT045         0   \n",
       "2017-12-26 11:01:24        1111     198  20190415154705265762TM29X5         0   \n",
       "2017-12-26 13:20:47        1112      99  2019041515470525583617ME1T         0   \n",
       "2017-12-26 15:14:08        1113     198  20190415154705260799JZG9PE         0   \n",
       "2017-12-27 11:10:44        1114     747  201904151547052706148Q9EUR         0   \n",
       "2017-12-27 11:44:07        1115     298  20190415154705280471UFM00J         0   \n",
       "2017-12-27 20:32:51        1116     498  20190415154705275516NRE3P3         0   \n",
       "2017-12-28 14:47:15        1117       0  20190415154705290007YF94X8         0   \n",
       "2017-12-28 16:55:21        1118     448  20190415154705285238A0E3CQ         0   \n",
       "2017-12-28 20:01:30        1119      99  20190415154705295044EO89UU         0   \n",
       "2017-12-29 11:54:40        1120     149  20190415154705299695TSY50A         0   \n",
       "2017-12-29 12:37:25        1121     199  20190415154705312232Q445LC         0   \n",
       "2017-12-29 18:28:30        1122     398  20190415154705317722AV2I6U         0   \n",
       "2017-12-29 18:51:16        1123     696  201904151547053072316M0C1C         0   \n",
       "2017-12-29 19:21:45        1124     198  20190415154705322455HFLPOG         0   \n",
       "2017-12-30 11:34:08        1125     199  20190415154705032764Z75VQK         0   \n",
       "2017-12-31 10:34:35        1126     715  201904151547053436824AQH3Y         0   \n",
       "2017-12-31 11:23:15        1127     547  20190415154705353833TQU9C1         0   \n",
       "2017-12-31 15:14:47        1128       0  20190415154705332302R0ZIKM         0   \n",
       "2017-12-31 17:12:01        1129     397  20190415154705337204XEXGUH         0   \n",
       "2017-12-31 20:50:11        1130     198  20190415154705348809QF0CXA         0   \n",
       "\n",
       "                     fk_clerk  fk_customer  fk_store     id  info  interests  \\\n",
       "created                                                                        \n",
       "2017-01-01 15:59:25       520          477         5  14955   NaN        250   \n",
       "2017-01-02 14:14:14       520          449         9  14959   NaN          0   \n",
       "2017-01-02 14:16:19       522          488         5  14960   NaN        200   \n",
       "2017-01-02 14:29:50       522          512         5  14957   NaN        200   \n",
       "2017-01-02 14:59:43       520          466         9  14956   NaN        125   \n",
       "2017-01-02 16:30:59       520          512         5  14958   NaN        350   \n",
       "2017-01-03 12:09:35        19          430         5  14961   NaN        380   \n",
       "2017-01-03 16:26:07        19          444         9  14963   NaN        100   \n",
       "2017-01-03 19:50:49       520          459         5  14964   NaN          0   \n",
       "2017-01-03 20:22:59       521          504         5  14962   NaN          0   \n",
       "2017-01-03 20:51:52       520          505         5  14965   NaN        225   \n",
       "2017-01-04 10:07:53       520          468         5  14970   NaN          0   \n",
       "2017-01-04 13:32:36       522          502         5  14968   NaN        130   \n",
       "2017-01-04 16:25:16        19          460         5  14966   NaN        175   \n",
       "2017-01-04 17:11:55       522          496         9  14967   NaN        100   \n",
       "2017-01-04 20:15:12        19          473         5  14969   NaN          0   \n",
       "2017-01-05 13:14:55        19          432         9  14971   NaN        100   \n",
       "2017-01-05 14:22:02        19          505         9  14972   NaN        125   \n",
       "2017-01-05 18:30:23       521          512         5  14973   NaN          0   \n",
       "2017-01-06 10:08:22       522          462         9  14974   NaN          0   \n",
       "2017-01-07 11:19:00       520          475         5  14975   NaN        100   \n",
       "2017-01-08 17:51:25       522          477         9  14976   NaN        100   \n",
       "2017-01-09 13:10:16       520          516         9  14978   NaN          0   \n",
       "2017-01-09 16:08:44        19          454         9  14980   NaN         50   \n",
       "2017-01-09 16:51:26        19          472         5  14981   NaN         50   \n",
       "2017-01-09 19:28:12       522          513         5  14977   NaN        100   \n",
       "2017-01-09 20:27:23       522          488         5  14979   NaN        350   \n",
       "2017-01-10 17:37:59        19          504         5  14982   NaN          0   \n",
       "2017-01-11 11:38:34       522          436         5  14983   NaN        230   \n",
       "2017-01-12 13:55:56       520          461         5  14984   NaN        150   \n",
       "...                       ...          ...       ...    ...   ...        ...   \n",
       "2017-12-22 18:01:43       520          429         9  16056   NaN         50   \n",
       "2017-12-23 11:58:43       522          439         5  16059   NaN        100   \n",
       "2017-12-23 16:23:01        19          500         9  16058   NaN        230   \n",
       "2017-12-23 17:18:40       522          458         9  16057   NaN        255   \n",
       "2017-12-24 11:38:13       520          483         5  16063   NaN        400   \n",
       "2017-12-24 14:14:29        19          430         9  16062   NaN        275   \n",
       "2017-12-24 15:04:36       522          495         5  16061   NaN        100   \n",
       "2017-12-24 18:21:44       521          471         9  16060   NaN        500   \n",
       "2017-12-24 19:49:35        19          467         9  16064   NaN        100   \n",
       "2017-12-25 20:16:54       521          501         5  16065   NaN        100   \n",
       "2017-12-26 11:01:24       522          453         9  16068   NaN        100   \n",
       "2017-12-26 13:20:47       521          431         9  16066   NaN         50   \n",
       "2017-12-26 15:14:08       520          515         9  16067   NaN        100   \n",
       "2017-12-27 11:10:44        19          457         9  16069   NaN        375   \n",
       "2017-12-27 11:44:07        19          474         5  16071   NaN        150   \n",
       "2017-12-27 20:32:51        19          487         9  16070   NaN        250   \n",
       "2017-12-28 14:47:15       522          462         9  16073   NaN          0   \n",
       "2017-12-28 16:55:21       522          452         5  16072   NaN        225   \n",
       "2017-12-28 20:01:30       520          517         9  16074   NaN         50   \n",
       "2017-12-29 11:54:40       521          477         5  16075   NaN         75   \n",
       "2017-12-29 12:37:25       520          478         9  16077   NaN        100   \n",
       "2017-12-29 18:28:30       520          516         5  16078   NaN        200   \n",
       "2017-12-29 18:51:16       521          474         5  16076   NaN        350   \n",
       "2017-12-29 19:21:45       522          441         5  16079   NaN        100   \n",
       "2017-12-30 11:34:08       520          502         9  16080   NaN        100   \n",
       "2017-12-31 10:34:35       522          495         9  16083   NaN        360   \n",
       "2017-12-31 11:23:15        19          476         9  16085   NaN        275   \n",
       "2017-12-31 15:14:47        19          440         9  16081   NaN          0   \n",
       "2017-12-31 17:12:01       521          428         9  16082   NaN        200   \n",
       "2017-12-31 20:50:11       520          432         9  16084   NaN        100   \n",
       "\n",
       "                                   modified  \n",
       "created                                      \n",
       "2017-01-01 15:59:25 2019-04-15 15:46:59.549  \n",
       "2017-01-02 14:14:14 2019-04-15 15:46:59.577  \n",
       "2017-01-02 14:16:19 2019-04-15 15:46:59.582  \n",
       "2017-01-02 14:29:50 2019-04-15 15:46:59.565  \n",
       "2017-01-02 14:59:43 2019-04-15 15:46:59.558  \n",
       "2017-01-02 16:30:59 2019-04-15 15:46:59.571  \n",
       "2017-01-03 12:09:35 2019-04-15 15:46:59.589  \n",
       "2017-01-03 16:26:07 2019-04-15 15:46:59.601  \n",
       "2017-01-03 19:50:49 2019-04-15 15:46:59.608  \n",
       "2017-01-03 20:22:59 2019-04-15 15:46:59.595  \n",
       "2017-01-03 20:51:52 2019-04-15 15:46:59.614  \n",
       "2017-01-04 10:07:53 2019-04-15 15:46:59.644  \n",
       "2017-01-04 13:32:36 2019-04-15 15:46:59.631  \n",
       "2017-01-04 16:25:16 2019-04-15 15:46:59.620  \n",
       "2017-01-04 17:11:55 2019-04-15 15:46:59.626  \n",
       "2017-01-04 20:15:12 2019-04-15 15:46:59.637  \n",
       "2017-01-05 13:14:55 2019-04-15 15:46:59.648  \n",
       "2017-01-05 14:22:02 2019-04-15 15:46:59.653  \n",
       "2017-01-05 18:30:23 2019-04-15 15:46:59.658  \n",
       "2017-01-06 10:08:22 2019-04-15 15:46:59.663  \n",
       "2017-01-07 11:19:00 2019-04-15 15:46:59.669  \n",
       "2017-01-08 17:51:25 2019-04-15 15:46:59.674  \n",
       "2017-01-09 13:10:16 2019-04-15 15:46:59.684  \n",
       "2017-01-09 16:08:44 2019-04-15 15:46:59.694  \n",
       "2017-01-09 16:51:26 2019-04-15 15:46:59.699  \n",
       "2017-01-09 19:28:12 2019-04-15 15:46:59.679  \n",
       "2017-01-09 20:27:23 2019-04-15 15:46:59.689  \n",
       "2017-01-10 17:37:59 2019-04-15 15:46:59.703  \n",
       "2017-01-11 11:38:34 2019-04-15 15:46:59.709  \n",
       "2017-01-12 13:55:56 2019-04-15 15:46:59.715  \n",
       "...                                     ...  \n",
       "2017-12-22 18:01:43 2019-04-15 15:47:05.206  \n",
       "2017-12-23 11:58:43 2019-04-15 15:47:05.221  \n",
       "2017-12-23 16:23:01 2019-04-15 15:47:05.216  \n",
       "2017-12-23 17:18:40 2019-04-15 15:47:05.211  \n",
       "2017-12-24 11:38:13 2019-04-15 15:47:05.241  \n",
       "2017-12-24 14:14:29 2019-04-15 15:47:05.236  \n",
       "2017-12-24 15:04:36 2019-04-15 15:47:05.231  \n",
       "2017-12-24 18:21:44 2019-04-15 15:47:05.226  \n",
       "2017-12-24 19:49:35 2019-04-15 15:47:05.246  \n",
       "2017-12-25 20:16:54 2019-04-15 15:47:05.251  \n",
       "2017-12-26 11:01:24 2019-04-15 15:47:05.266  \n",
       "2017-12-26 13:20:47 2019-04-15 15:47:05.256  \n",
       "2017-12-26 15:14:08 2019-04-15 15:47:05.261  \n",
       "2017-12-27 11:10:44 2019-04-15 15:47:05.271  \n",
       "2017-12-27 11:44:07 2019-04-15 15:47:05.280  \n",
       "2017-12-27 20:32:51 2019-04-15 15:47:05.276  \n",
       "2017-12-28 14:47:15 2019-04-15 15:47:05.290  \n",
       "2017-12-28 16:55:21 2019-04-15 15:47:05.285  \n",
       "2017-12-28 20:01:30 2019-04-15 15:47:05.295  \n",
       "2017-12-29 11:54:40 2019-04-15 15:47:05.300  \n",
       "2017-12-29 12:37:25 2019-04-15 15:47:05.312  \n",
       "2017-12-29 18:28:30 2019-04-15 15:47:05.318  \n",
       "2017-12-29 18:51:16 2019-04-15 15:47:05.307  \n",
       "2017-12-29 19:21:45 2019-04-15 15:47:05.322  \n",
       "2017-12-30 11:34:08 2019-04-15 15:47:05.328  \n",
       "2017-12-31 10:34:35 2019-04-15 15:47:05.344  \n",
       "2017-12-31 11:23:15 2019-04-15 15:47:05.354  \n",
       "2017-12-31 15:14:47 2019-04-15 15:47:05.332  \n",
       "2017-12-31 17:12:01 2019-04-15 15:47:05.337  \n",
       "2017-12-31 20:50:11 2019-04-15 15:47:05.349  \n",
       "\n",
       "[1131 rows x 11 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df1 = df.copy()\n",
    "df1.loc[ df1['amount'] == 0 ]\n",
    "df1.set_index('created', inplace=True, drop=True)  # default inplace=False return new df; default drop=True delete columns becoming index \n",
    "# df1.reset_index()\n",
    "# df.shape \n",
    "\n",
    "\n",
    "# Partial String Indexing\n",
    "# http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#partial-string-indexing\n",
    "df1['2017/1':'2017']  # 2013-2-28 00:00:00\n",
    "\n",
    "# There are several time/date properties that one can access from Timestamp or a collection of timestamps like a DatetimeIndex.\n",
    "# http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#time-date-components\n",
    "\n",
    "# Offset Aliases\n",
    "# http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#offset-aliases\n",
    "\n",
    "# Combining Aliases\n",
    "\n",
    "# anchored-offsets\n",
    "# http://pandas.pydata.org/pandas-docs/stable/user_guide/timeseries.html#anchored-offsets\n",
    "\n",
    "\n",
    "# business day weekday\n",
    "# business hour 上班时间"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Group:  2017-01-01 00:00:00\n",
      "<class 'pandas._libs.tslibs.timestamps.Timestamp'>\n",
      "---------------------------\n",
      "sum: amount       498\n",
      "interests    250\n",
      "dtype: int64\n",
      "                     amount  interests\n",
      "created                               \n",
      "2017-01-01 15:59:25     498        250\n",
      "\n",
      "Group:  2017-01-02 00:00:00\n",
      "<class 'pandas._libs.tslibs.timestamps.Timestamp'>\n",
      "---------------------------\n",
      "sum: amount       1740\n",
      "interests     875\n",
      "dtype: int64\n",
      "                     amount  interests\n",
      "created                               \n",
      "2017-01-02 14:16:19     398        200\n",
      "2017-01-02 14:29:50     398        200\n",
      "2017-01-02 14:59:43     248        125\n",
      "2017-01-02 16:30:59     696        350\n",
      "\n",
      "Group:  2017-01-03 00:00:00\n",
      "<class 'pandas._libs.tslibs.timestamps.Timestamp'>\n",
      "---------------------------\n",
      "sum: amount       1402\n",
      "interests     705\n",
      "dtype: int64\n",
      "                     amount  interests\n",
      "created                               \n",
      "2017-01-03 12:09:35     756        380\n",
      "2017-01-03 16:26:07     198        100\n",
      "2017-01-03 20:51:52     448        225\n",
      "\n",
      "Group:  2017-01-04 00:00:00\n",
      "<class 'pandas._libs.tslibs.timestamps.Timestamp'>\n",
      "---------------------------\n",
      "sum: amount       606\n",
      "interests    305\n",
      "dtype: int64\n",
      "                     amount  interests\n",
      "created                               \n",
      "2017-01-04 13:32:36     258        130\n",
      "2017-01-04 16:25:16     348        175\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>created</th>\n",
       "      <th>amount</th>\n",
       "      <th>interests</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>498</td>\n",
       "      <td>250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2017-01-02</td>\n",
       "      <td>1740</td>\n",
       "      <td>875</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2017-01-03</td>\n",
       "      <td>1402</td>\n",
       "      <td>705</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2017-01-04</td>\n",
       "      <td>606</td>\n",
       "      <td>305</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     created  amount  interests\n",
       "0 2017-01-01     498        250\n",
       "1 2017-01-02    1740        875\n",
       "2 2017-01-03    1402        705\n",
       "3 2017-01-04     606        305"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2 = df1.loc[lambda x:x.amount > 0,['amount','interests']]\n",
    "df2 = df2.head(10) \n",
    "resampled = df2.resample('D')  # D W 3D 1D12H ...\n",
    "for name, group in resampled:\n",
    "    print(\"Group: \", name)\n",
    "    print(type(name))\n",
    "    print(\"-\" * 27)\n",
    "    print(\"sum:\", group.sum())  # mean \n",
    "    print(group, end=\"\\n\\n\")\n",
    "\n",
    "# resampled.mean()\n",
    "# resampled['amount'].agg([np.sum, np.mean, np.std])\n",
    "\n",
    "df2.truncate(before='2017-01-02', after='2017-01-04')  # [before,after)\n",
    "df2['2017/01/02':'2017/01/03']\n",
    "from datetime import date, datetime\n",
    "df2[datetime(2017,1,2):datetime(2017,1,3,22)]\n",
    "df2.reset_index().to_dict(orient='split')\n",
    "\n",
    "# df3 = df2.reset_index()['created'].apply(  lambda x: int(x.timestamp()) * 1000 ) \n",
    "df3 = df2.reset_index()\n",
    "df3['created'] = df3['created'].apply(  lambda x: int(x.timestamp()) * 1000 ) \n",
    "df3\n",
    "\n",
    "# resampled.sum().reset_index().to_dict(orient=\"split\")[\"data\"]\n",
    "resampled.sum().reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2011-01-02', '2011-01-09', '2011-01-16', '2011-01-23',\n",
       "               '2011-01-30', '2011-02-06', '2011-02-13', '2011-02-20',\n",
       "               '2011-02-27', '2011-03-06', '2011-03-13', '2011-03-20',\n",
       "               '2011-03-27', '2011-04-03', '2011-04-10', '2011-04-17',\n",
       "               '2011-04-24', '2011-05-01', '2011-05-08', '2011-05-15',\n",
       "               '2011-05-22', '2011-05-29', '2011-06-05', '2011-06-12',\n",
       "               '2011-06-19', '2011-06-26', '2011-07-03', '2011-07-10',\n",
       "               '2011-07-17', '2011-07-24', '2011-07-31', '2011-08-07',\n",
       "               '2011-08-14', '2011-08-21', '2011-08-28', '2011-09-04',\n",
       "               '2011-09-11', '2011-09-18', '2011-09-25', '2011-10-02',\n",
       "               '2011-10-09', '2011-10-16', '2011-10-23', '2011-10-30',\n",
       "               '2011-11-06', '2011-11-13', '2011-11-20', '2011-11-27',\n",
       "               '2011-12-04', '2011-12-11', '2011-12-18', '2011-12-25',\n",
       "               '2012-01-01'],\n",
       "              dtype='datetime64[ns]', freq='W-SUN')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "'''\n",
    "Pandas API Reference General functions\n",
    "http://pandas.pydata.org/pandas-docs/stable/reference/general_functions.html\n",
    "\n",
    "pd.to_datetime() \n",
    "\n",
    "pd.date_range()  # periods freq\n",
    "\n",
    "pd.Timestamp()\n",
    "pd.Period()\n",
    "\n",
    "'''\n",
    "from datetime import date, datetime\n",
    "start = datetime(2011, 1, 1)\n",
    "end = datetime(2012, 1, 1)\n",
    "pd.date_range(start, end, freq='BM')\n",
    "pd.date_range(start, end, freq='W')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1483228800000, 498], [1483315200000, 1740], [1483401600000, 1402], [1483488000000, 804], [1483574400000, 447], [1483660800000, 0], [1483747200000, 198], [1483833600000, 198]]\n",
      "[[1483228800000, 498], [1483315200000, 1740], [1483401600000, 1402], [1483488000000, 804], [1483574400000, 447], [1483660800000, 0], [1483747200000, 198], [1483833600000, 198]]\n",
      "[{'data': [[1483228800000, 498], [1483315200000, 1740], [1483401600000, 1402], [1483488000000, 804], [1483574400000, 447], [1483660800000, 0], [1483747200000, 198], [1483833600000, 198]]}, {'data': [[1483228800000, 498], [1483315200000, 1740], [1483401600000, 1402], [1483488000000, 804], [1483574400000, 447], [1483660800000, 0], [1483747200000, 198], [1483833600000, 198]]}]\n"
     ]
    }
   ],
   "source": [
    "df4 = df1.copy().reset_index().loc[lambda x:x.amount > 0,['created','fk_store','amount','interests']][:15]\n",
    "stores = [5,9]\n",
    "series = []\n",
    "for store in stores:\n",
    "    temp = df4.copy().set_index('created')\n",
    "    temp = temp.resample(\"D\").sum()\n",
    "    temp = temp.reset_index()\n",
    "    temp['created'] = temp['created'].apply(\n",
    "         lambda x: int(\n",
    "                x.timestamp()\n",
    "            ) * 1000  # Javascript Date.getTime() return millisecond rather than second\n",
    "    )\n",
    "    temp = temp.loc[:,['created','amount']].to_dict(orient=\"split\")[\"data\"]\n",
    "    series.append({\n",
    "        \"data\":temp\n",
    "    })\n",
    "    print(temp)\n",
    "print(series)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
